package com.woniuxy.store.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.store.core.model.PmMessage;
import com.woniuxy.store.core.service.PmMessageService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-07-06
 */
@RestController
@RequestMapping("pmMessage")
public class PmMessageController {
    @Resource
    private PmMessageService messageService;
    /**
     * Description : 门店查看系统发布的公告信息。
     * ChangeLog : 1. 创建 (2021/7/6 14:46 [fulang]); 
     *
     * @return com.woniuxy.common.CommonResult<java.util.List<com.woniuxy.store.core.model.PmMessage>>
    */
    @GetMapping("selectAnnouncementMessage")
    public CommonResult<List<PmMessage>> selectAnnouncementMessage(){
        List<PmMessage> pmMessages = messageService.selectAnnouncementMessage();
        return CommonResult.success(pmMessages);
    }
    /**
     * Description : 门店查看系统的消息通知。
     * ChangeLog : 1. 创建 (2021/7/6 14:47 [fulang]); 
     * @param storeId  
     * @return com.woniuxy.common.CommonResult<java.util.List<com.woniuxy.store.core.model.PmMessage>>
    */
    @GetMapping("selectNotification")
    public CommonResult<List<PmMessage>> selectNotification(Integer storeId){
        List<PmMessage> pmMessages = messageService.selectNotification(storeId);
        return CommonResult.success(pmMessages);
    }
    /**
     * Description : 门店查看系统发布的活动通知。
     * ChangeLog : 1. 创建 (2021/7/6 14:48 [fulang]);
     *
     * @return com.woniuxy.common.CommonResult<java.util.List<com.woniuxy.store.core.model.PmMessage>>
    */
    @GetMapping("selectEventNotification")
    public CommonResult<List<PmMessage>> selectEventNotification( ){
        List<PmMessage> pmMessages = messageService.selectEventNotification();
        return CommonResult.success(pmMessages);
    }


    /**
     * Description : 审核通过后发布消息通知  <br/>
     * ChangeLog : 1. 创建 (2021/7/13 15:12 [binhu]);
     * @param storeId  
     * @return com.woniuxy.common.CommonResult
    */
    @PostMapping("/postAMessageNotificationAfterApproval/{storeId}")
    public CommonResult postAMessageNotificationAfterApproval(@PathVariable Integer storeId){
        int row = messageService.postAMessage(storeId);
        if(row==0){
            return CommonResult.fail("通知失败");
        }
        return CommonResult.success("通知成功");
    }
    
}

